/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.click.app.model;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 *
 * @author ronald
 */
@Entity
@Table(name = "pant_detail_cut_detail")
public class PantDetailCutDetail  extends BaseObject implements Serializable {
    private static final long serialVersionUID = 1L;
    private Long id;

    private Integer quantity;
    private CutDetail cutDetail;
    private PantDetail pantDetail;

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @Column(name="id_pant_detail_cut_detail", unique=true, nullable=false)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="id_cut_detail", nullable = false)
    public CutDetail getCutDetail() {
        return cutDetail;
    }

    public void setCutDetail(CutDetail cutDetail) {
        this.cutDetail = cutDetail;
    }

    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="id_pant_detail", nullable = false)
    public PantDetail getPantDetail() {
        return pantDetail;
    }

    public void setPantDetail(PantDetail pantDetail) {
        this.pantDetail = pantDetail;
    }

    @Column(name="quantity", nullable=false)
    public Integer getQuantity() {
        return quantity;
    }

    public void setQuantity(Integer quantity) {
        this.quantity = quantity;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.SIMPLE_STYLE).append(this.getId())
                   .append(this.cutDetail).append(this.pantDetail)
                   .toString();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final PantDetailCutDetail other = (PantDetailCutDetail) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        if (this.quantity != other.quantity && (this.quantity == null || !this.quantity.equals(other.quantity))) {
            return false;
        }
        if (this.cutDetail != other.cutDetail && (this.cutDetail == null || !this.cutDetail.equals(other.cutDetail))) {
            return false;
        }
        if (this.pantDetail != other.pantDetail && (this.pantDetail == null || !this.pantDetail.equals(other.pantDetail))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 61 * hash + (this.id != null ? this.id.hashCode() : 0);
        hash = 61 * hash + (this.quantity != null ? this.quantity.hashCode() : 0);
        hash = 61 * hash + (this.cutDetail != null ? this.cutDetail.hashCode() : 0);
        hash = 61 * hash + (this.pantDetail != null ? this.pantDetail.hashCode() : 0);
        return hash;
    }

}
